// 控制弹出层后 下面内容不在滚动
const scroll = {
  beforeRouteLeave(to, from, next) {
    this.scroll(true)
    next()
  },
  methods: {
    scroll(p) {
      if (p) {
        document.body.removeEventListener('touchmove', stopTouch, {
          capture: true,
        })
        document.body.removeEventListener('mousewheel', stopTouch, {
          capture: true,
        })
      } else {
        document.body.addEventListener('touchmove', stopTouch, {
          passive: false,
          capture: true,
        })
        document.body.addEventListener('mousewheel', stopTouch, {
          passive: false,
          capture: true,
        })
      }
    },
  },
}

function stopTouch(e) {
  e.preventDefault()
}
export default scroll
